use Illuminate\Contracts\Support\DeferrableProvider;
class ClientSocketServiceProvider extends ServiceProvider implements DeferrableProvider {
protected $defer = true;
public function provides() {
return [
ClientSocket::class,
];
}
}
php artisan make:middleware ProductDelete
# 位於 app/Http/Middleware/ProductDelete
class ProductDelete {
public function handle($request, Closure $new){
return $next($request);
}
}
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
];
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
];
# 套用路由 middleware
Route::get('product', [ProductController:class, 'create')->middleware('auth');
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];